//
//  BIDPayRecordDetailViewController.m
//  zkwy
//
//  Created by mal on 2016/11/14.
//  Copyright © 2016年 mal. All rights reserved.
//

#import "BIDPayRecordDetailViewController.h"
#import "BIDPayRecordDetailCell.h"

@interface BIDPayRecordDetailViewController ()
{
    BOOL _bRegister;
}
@end

@implementation BIDPayRecordDetailViewController
@synthesize payRecordDetailArr;

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"缴费详情";
    self.tableView.tableFooterView = [[UIView alloc] init];
    self.tableView.allowsSelection = NO;
    //self.tableView.backgroundColor = RGBACOLOR(242, 242, 242, 1);
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return payRecordDetailArr.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSUInteger row = indexPath.row;
    static NSString *identifier = @"identifier";
    UITableViewCell *cell = nil;
    if(!_bRegister)
    {
        _bRegister = YES;
        UINib *nib = [UINib nibWithNibName:@"BIDPayRecordDetailCell" bundle:nil];
        [tableView registerNib:nib forCellReuseIdentifier:identifier];
    }
    NSDictionary *dic = payRecordDetailArr[row];
    BIDPayRecordDetailCell *detailCell = [tableView dequeueReusableCellWithIdentifier:identifier];
    detailCell.feeTypeNameLabel.text = dic[@"feeTypeName"];
    if(ISNULL(dic[@"payableFee"]))
    {
        detailCell.amountLabel.text = @"";
    }
    else
    {
        detailCell.amountLabel.text = [[NSString alloc] initWithFormat:@"%@元", ANY2NSSTRING(dic[@"payableFee"])];
    }
    if(ISNULL(dic[@"privilege"]))
    {
        detailCell.privilegeLabel.text = @"";
    }
    else
    {
        detailCell.privilegeLabel.text = [[NSString alloc] initWithFormat:@"%@元", ANY2NSSTRING(dic[@"privilege"])];
    }
    detailCell.finalAmountLabel.text = [[NSString alloc] initWithFormat:@"%@元", ANY2NSSTRING(dic[@"finalFee"])];
    if(ISNULL(dic[@"feeDate"]))
    {
        detailCell.yearLabel.text = @"";
    }
    else
    {
        detailCell.yearLabel.text = [[NSString alloc] initWithFormat:@"%@", ANY2NSSTRING(dic[@"feeDate"])];
    }
    detailCell.dateLabel.text = dic[@"payTime"];
    cell = detailCell;
    [cell setBackgroundColor:[UIColor clearColor]];
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 105.f;
}

@end
